package com.da.javatest.demo.basic;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: chenlida
 * @Date: 2018/11/9 14:44
 * @Description:
 */
public class FunctionTest {
    public static void main(String[] args) {
        //Function<Integer, Integer> fun = x -> x + 1;

        Function<String, String> fun1 = Function.identity();
        String str1 = fun1.apply("helloWorld");
        System.out.println(str1);

        List<Student> students = Arrays.asList(new Student(1, "aa", 18), new Student(2, "bb", 19),
            new Student(3, "cc", 18), new Student(4, "aa", 19));

        Map<Integer, Student> map = students.stream().collect(
            Collectors.toMap(Student::getId, Function.identity()));
        System.out.println(map);
    }
}

